package com.architecture.core.web.actions;

import com.architecture.core.web.vo.PageDataVO;
import com.architecture.core.web.vo.UserQueryVO;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.stereotype.Controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <p>Project: BTC</p>
 * <p>Description: </p>
 * <p>Copyright (c) 2012 Wilmar Consultancy Services</p>
 * <p>All Rights Reserved.</p>
 *
 * @author <a href="mailto:hujianguang@wcs-global.com">胡建光</a>
 */
@Controller("userListAction")
@Results({
        @Result(name = "list", location = "front/user/user.jsp")
})
public class UserListAction extends AbstractAction {

//    @Resource
//    private BaseUserService baseUserService;
//
//    @Resource
//    private BasePermissionService basePermissionService;

    private UserQueryVO userQueryVO = new UserQueryVO();

    private PageDataVO pageDataVO = new PageDataVO();

    private List<Map<String, Object>> userList = new ArrayList<Map<String, Object>>();

    /**
     * A default implementation that does nothing an returns "success".
     * <p/>
     * Subclasses should override this method to provide their business logic.
     * <p/>
     * See also {@link com.opensymphony.xwork2.Action#execute()}.
     *
     * @return returns {@link #SUCCESS}
     * @throws Exception can be thrown by subclasses.
     */
    @Override
    @Action(value = "user")
    public String execute() {
        try {
            return super.execute();
        } catch (Exception ex) {

        }
        return null;
    }

//    @Action(value = "query_user_list")
//    public String queryUserList() {
//
//        try {
//            String queryHql = HqlUtils.assemblyUserHql(this.getUserQueryVO(), User.class);
//            Integer firstIndex = this.getPageDataVO().getCurrentPage() - 1 * ConfigUtil.getInt(ConfigUtil.W_DEFAULT_PAGE_SIZE);
//            this.setUserList(this.baseUserService.queryListOfMapByPermission(queryHql, firstIndex, super.getSessionMap().get(super.CURRENT_ID).toString()));
//
//            return super.LIST;
//        } catch (ErrException err) {
//            err.printStackTrace();
//            super.addActionError(err.getMessage());
//        }
//
//        return super.ERROR;
//
//    }

    public UserQueryVO getUserQueryVO() {
        return userQueryVO;
    }

    public void setUserQueryVO(UserQueryVO userQueryVO) {
        this.userQueryVO = userQueryVO;
    }

    public List<Map<String, Object>> getUserList() {
        return userList;
    }

    public void setUserList(List<Map<String, Object>> userList) {
        this.userList = userList;
    }

    public PageDataVO getPageDataVO() {
        return pageDataVO;
    }

    public void setPageDataVO(PageDataVO pageDataVO) {
        this.pageDataVO = pageDataVO;
    }
}
